//
//  EWTitleCommonCell.m
//  haveSomethingToEat
//
//  Created by 陈 宁权 on 17/4/10.
//  Copyright © 2017年 陈 宁权. All rights reserved.
//

#import "EWTitleCommonCell.h"

@interface EWTitleCommonCell()
@property (nonatomic,strong) UILabel *headingsLabel;
@property (nonatomic,strong) UILabel *subheadingsLabel;
@end

@implementation EWTitleCommonCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"EWCommonCell";
    // 1.缓存中取
    EWTitleCommonCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    // 2.创建
    if (cell == nil) {
        cell = [[EWTitleCommonCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupChildViews];
    }
    return self;
}

- (void)setupChildViews
{
    //主标题
    _headingsLabel = [[UILabel alloc] init];
    _headingsLabel.textAlignment = NSTextAlignmentLeft;
    _headingsLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_headingsLabel];
    
    //副标题
    _subheadingsLabel = [[UILabel alloc] init];
    _subheadingsLabel.textAlignment = NSTextAlignmentRight;
    _subheadingsLabel.font = [UIFont systemFontOfSize:13];
    _subheadingsLabel.alpha = 0.5;
    [self.contentView addSubview:_subheadingsLabel];
    
    [_headingsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.left.equalTo(self).offset(20);
        make.bottom.equalTo(self);
        make.width.offset(150);
    }];
    
    [_subheadingsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.bottom.equalTo(self);
        make.right.equalTo(self).offset(-30);
        make.left.equalTo(_headingsLabel.mas_right).offset(10);
    }];
}

- (void)setHeadingText:(NSString *)headingText
{
    _headingText = headingText;
    _headingsLabel.text = _headingText;
}

- (void)setSubheadingText:(NSString *)subheadingText
{
    _subheadingText = subheadingText;
    _subheadingsLabel.text = _subheadingText;
}


@end
